package com.huawei.appgallery.forum.message.card;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.huawei.appgallery.forum.base.card.ForumCard;
import com.huawei.appgallery.forum.base.card.bean.User;
import com.huawei.appgallery.forum.cards.widget.UserHeadImageView;
import com.huawei.appgallery.forum.cards.widget.UserInfoTextView;
import com.huawei.appgallery.forum.message.bean.ForumRemindFollowCardBean;
import com.huawei.appgallery.forum.user.api.IUserFollow;
import com.huawei.appgallery.forum.user.api.IUserHomePageProtocol;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import huawei.widget.HwButton;
import o.azb;
import o.bqx;
import o.bqy;
import o.brd;
import o.bsp;
import o.bsx;
import o.bsy.e;
import o.btc;
import o.bvj.b;
import o.bvj.d;
import o.bvj.j;
import o.cgz;
import o.chy;
import o.evx;
import o.fho;
import o.fiu;
import o.fjb;
import o.fjo;
import o.fjq;
import o.fjt;

public class ForumRemindFollowCard extends ForumCard implements OnClickListener {
    private ForumRemindFollowCardBean ˊ;
    private UserInfoTextView ˋ;
    private UserHeadImageView ˎ;
    private HwButton ˏ;
    private TextView ॱ;
    private a ॱॱ = new a(this);
    private User ᐝ;

    static final class a extends evx {
        private OnClickListener ˎ;

        a(OnClickListener onClickListener) {
            this.ˎ = onClickListener;
        }

        public void ˋ(View view) {
            this.ˎ.onClick(view);
        }
    }

    public ForumRemindFollowCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ʽ(view);
        this.ˎ = (UserHeadImageView) view.findViewById(b.ˈ);
        this.ˋ = (UserInfoTextView) view.findViewById(b.ʽॱ);
        this.ॱ = (TextView) view.findViewById(b.ॱˎ);
        this.ˏ = (HwButton) view.findViewById(b.ॱˋ);
        this.ˏ.setOnClickListener(this.ॱॱ);
        this.ˎ.setOnClickListener(this.ॱॱ);
        view.setOnClickListener(this.ॱॱ);
        this.ˋ.setNickNameTextSize(this.ʼॱ.getResources().getDimension(d.ॱ));
        return this;
    }

    public void onClick(View view) {
        if (view.getId() == b.ॱˋ) {
            int i = 0;
            if (this.ˊ.ˊ().ʻॱ() == 1 || this.ˊ.ˊ().ʻॱ() == 2) {
                i = 1;
            }
            ˋ(i);
            return;
        }
        ˎ(this.ˊ);
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof ForumRemindFollowCardBean) {
            ˏ((ForumRemindFollowCardBean) cardBean);
        }
    }

    private void ˏ(ForumRemindFollowCardBean forumRemindFollowCardBean) {
        this.ˊ = forumRemindFollowCardBean;
        this.ᐝ = forumRemindFollowCardBean.ˊ();
        ˎ();
        if (this.ᐝ == null || this.ᐝ.ॱ() == null || TextUtils.isEmpty(this.ᐝ.ˎ())) {
            this.ˎ.setImageResource(o.bsy.a.ॱˋ);
        } else {
            bsx.ˏ(this.ʼॱ, this.ˎ, forumRemindFollowCardBean.ˊ().ˎ());
        }
        ˊ(this.ॱ, btc.ˏ(this.ʼॱ, forumRemindFollowCardBean.ᐝ()));
    }

    private void ˎ() {
        if (this.ᐝ == null || this.ᐝ.ॱ() == null) {
            User user = new User();
            user.ˎ(this.ʼॱ.getResources().getString(j.ˏ));
            this.ˋ.setData(user);
            this.ᐝ = user;
            this.ˏ.setVisibility(8);
            return;
        }
        this.ˏ.setVisibility(0);
        ॱॱ();
        int ˏ = bsp.ˏ(this.ˏ, this.ˏ.getText().toString());
        if (ˏ < this.ʼॱ.getResources().getDimensionPixelOffset(e.ˌ)) {
            ˏ = this.ʼॱ.getResources().getDimensionPixelOffset(e.ˌ);
        }
        ˏ = ((azb.ॱ(this.ʼॱ) - (this.ʼॱ.getResources().getDimensionPixelOffset(e.ʿ) * 4)) - this.ʼॱ.getResources().getDimensionPixelOffset(e.ˎˎ)) - ˏ;
        if (!this.ᐝ.ʼ()) {
            this.ˋ.setContentWidth(ˏ);
        }
        this.ˋ.setData(this.ᐝ);
    }

    private void ॱॱ() {
        switch (this.ᐝ.ʻॱ()) {
            case 0:
                this.ˏ.setText(j.ᶥ);
                this.ˏ.setTextColor(this.ʼॱ.getResources().getColor(o.bvj.a.ˋ));
                return;
            case 1:
                this.ˏ.setText(j.ᐨ);
                this.ˏ.setTextColor(this.ʼॱ.getResources().getColor(o.bvj.a.ˊ));
                return;
            case 2:
                this.ˏ.setText(j.ᐝᐝ);
                this.ˏ.setTextColor(this.ʼॱ.getResources().getColor(o.bvj.a.ˊ));
                return;
            default:
                return;
        }
    }

    public void ॱ(chy o_chy) {
    }

    private void ˎ(ForumRemindFollowCardBean forumRemindFollowCardBean) {
        fjb ˎ = fho.ˏ().ˋ("User").ˎ("UserHomePageActivity");
        if (!(this.ᐝ == null || this.ᐝ.ॱ() == null)) {
            IUserHomePageProtocol iUserHomePageProtocol = (IUserHomePageProtocol) ˎ.ˊ();
            iUserHomePageProtocol.setUri("forum|user_detail");
            iUserHomePageProtocol.setUserId(this.ᐝ.ॱ());
            iUserHomePageProtocol.setType(this.ᐝ.ˊ());
            iUserHomePageProtocol.setDomainId(forumRemindFollowCardBean.ॱ());
        }
        fiu.ˊ().ˏ(ˉ().getContext(), ˎ);
    }

    private void ˋ(final int i) {
        if (this.ᐝ != null) {
            ((IUserFollow) fho.ˏ().ˋ("User").ॱ(IUserFollow.class)).ॱ(ˉ().getContext(), this.ᐝ, i).ˋ(fjt.ˎ(), new fjq<IUserFollow.b>(this) {
                final /* synthetic */ ForumRemindFollowCard ॱ;

                public void onComplete(fjo<IUserFollow.b> o_fjo_com_huawei_appgallery_forum_user_api_IUserFollow_b) {
                    IUserFollow.b bVar = (IUserFollow.b) o_fjo_com_huawei_appgallery_forum_user_api_IUserFollow_b.ॱ();
                    if (o_fjo_com_huawei_appgallery_forum_user_api_IUserFollow_b.ˊ() && bVar.ˏ() == 0) {
                        bqx.ˊ("ForumRemindFollowCard", "follow action success");
                        int ˋ = ((IUserFollow.b) o_fjo_com_huawei_appgallery_forum_user_api_IUserFollow_b.ॱ()).ˋ();
                        if (ˋ != this.ॱ.ᐝ.ʻॱ()) {
                            this.ॱ.ᐝ.ˎ(ˋ);
                            this.ॱ.ˎ();
                            brd.ॱ.ˋ(bqy.ˋ().ˎ(this.ॱ.ʼॱ), bqy.ˋ().ˎ(), this.ॱ.ˊ.ॱˈ(), "MESSAGE", i == 0 ? 1 : 0);
                        }
                    }
                }
            });
        }
    }
}
